package com.fyt.reachgo.controller;

import com.fyt.reachgo.domain.City;
import com.fyt.reachgo.domain.Result;
import com.fyt.reachgo.domain.VO.CityCallingCardVO;
import com.fyt.reachgo.domain.dto.CityCallingCardDTO;
import com.fyt.reachgo.service.CityService;
import com.fyt.reachgo.service.ProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/CityCallingCard")
public class CityCallingCardController {

    @Autowired
    private ProvinceService provinceService;
    @Autowired
    private CityService cityService;

    /**
     * 获取省份列表
     * @return
     */
    @RequestMapping("/getProvinceList")
    public Result<List<CityCallingCardVO>> getProvinceList(){
        return provinceService.getProvinceList();
    }

    /**
     * 获取城市列表
     * @param cityCallingCardDTO
     * @return
     */
    @RequestMapping("/getCityList")
    public Result<List<CityCallingCardVO>> getCityList(@RequestBody CityCallingCardDTO cityCallingCardDTO){
        return cityService.getCityList(cityCallingCardDTO);
    }

    /**
     * 获取城市信息
     * @param cityCallingCardDTO
     * @return
     */
    @RequestMapping("/getCity")
    public Result<City> getCity(@RequestBody CityCallingCardDTO cityCallingCardDTO){
        return cityService.getCityById(cityCallingCardDTO);
    }

}
